<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>系统后台 - {$Think.config.INTENDANT_NAME} - by HemaCMS</title>
    <link href="__INTENDANT__/css/admin_style.css" rel="stylesheet" />
    <script src="__COMMON__/jquery.js"></script>
    <script src="__COMMON__/jquery.cookie.js"></script>
    <script src="__COMMON__/jquery.validate.min.js"></script> <!--表单验证-->
    <script src="__COMMON__/layer/layer.js"></script>
    <script src="__INTENDANT__/js/iteny.intendant.js"></script> <!-- 公共easyui JS -->
    <!-- <link href="__INTENDANT__/css/icons.css" rel="stylesheet" /> -->
    <link href="__INTENDANT__/css/iteny.css" rel="stylesheet" />

</head>
<body class="J_scroll_fixed">
<div class="wrap J_check_wrap">
   	<div class="nav">
	    <ul class="cc">
	        <li class="current"><a href="{:U('Index/userPass')}">修改密码</a></li>
	    </ul>
	 </div>
   <div class="table_list">
     <form class="J_ajaxForm" action="{:U('Index/userPass')}" name="editUser" method="post" id="editUser">

     <div class="h_a">基本属性</div>
     <div class="table_full">
     <table width="100%" class="table_form contentWrap">
          <input type="hidden" name="editUser" value="editUser" />
          <tbody>
			<tr>
              <th width="80">账户名</th>
              <td>{$Think.session.admin_user}</td>
            </tr>
            <tr>
              <th width="80">密码</th>
              <td><input type="password" name="password" class="input length_4" id="password" value=""></td>
            </tr>
            <tr>
              <th width="80">确认密码</th>
              <td><input type="password" name="passworded" class="input length_4" id="passworded" value=""></td>
            </tr>

          </tbody>
        </table>
     </div>
     <div class="btn_wrap">
        <div class="btn_wrap_pd">
          <button class="btn btn_submit mr10 J_ajax_submit_btn" type="submit">修改</button>
        </div>
      </div>
      </form>
    </div>
</div>
<script type="text/javascript">
var userdizhi = "{:U('Index/userPass')}";

$(function(){

  jQuery.validator.addMethod("password", function(value, element) {
  var tel = /^[a-zA-Z][\w]{7,16}$/;
  return this.optional(element) || (tel.test(value));
  }, "以字母开头,8-17 字母、数字、下划线'_'");

  $('form[name=editUser]').validate({
    errorElement : 'span',
    validClass: "success",  //非常重要
    success : function (label) {
      label.addClass('success');
    },

        rules : {


                password : {
                   // required : true,
                   password : true
                },
                passworded : {
                   // required : true,
                   equalTo : "#password"
                },

            },
        messages : {

                password : {
                    // required : "请输入密码"
                },
                passworded : {
                    // required : '请确认密码',
                    equalTo : '两次密码不一致'
                },

            },
            submitHandler: function(form)
            {
              if($('.J_ajax_submit_btn').attr("disabledSubmit")){
              $('.J_ajax_submit_btn').text('请勿重复提交...').prop('disabled', true).addClass('disabled');
              return false;
          }
        $('.J_ajax_submit_btn').attr("disabledSubmit",true);
            var param = $('form[name=editUser]').serialize();
            $.ajax({
              url: $('form[name=editUser]').attr('action'),
              dataType:'json',
              type:'POST',
              data:param,
              success: function(data) {
                if (data=='-20') {
                  ITENY.alert('提示','修改账户成功',1,'5000');
                  setTimeout(function(){
                      window.location.href=userdizhi;
                  },3000);
              }else if(data=='-2')
              {
                ITENY.alert('提示',"账号以字母开头,5-17 字母、数字、下划线'_'",2,'5000');
                $('.J_ajax_submit_btn').text('添加').removeProp('disabled').removeClass('disabled');
                $('.J_ajax_submit_btn').attr("disabledSubmit",'');            }
                else if(data=='-3')
                {
                  ITENY.alert('提示','账户名被占用',2,'5000');
                  $('.J_ajax_submit_btn').text('添加').removeProp('disabled').removeClass('disabled');
                  $('.J_ajax_submit_btn').attr("disabledSubmit",'');
                }
                else if(data=='-4')
                {
                  ITENY.alert('提示','昵称必须是中文',2,'5000');
                  $('.J_ajax_submit_btn').text('添加').removeProp('disabled').removeClass('disabled');
                  $('.J_ajax_submit_btn').attr("disabledSubmit",'');
                }
                else if(data=='-5')
                {
                  ITENY.alert('提示','昵称被占用',2,'5000');
                  $('.J_ajax_submit_btn').text('添加').removeProp('disabled').removeClass('disabled');
                  $('.J_ajax_submit_btn').attr("disabledSubmit",'');
                }
                else if(data=='-6'){
                  ITENY.alert('提示',"密码以字母开头,8-17 字母、数字、下划线'_'",2,'5000');
                  $('.J_ajax_submit_btn').text('添加').removeProp('disabled').removeClass('disabled');
                  $('.J_ajax_submit_btn').attr("disabledSubmit",'');
                }
                else if(data=='-7'){
                  ITENY.alert('提示','验证确认密码是否和密码一致',2,'5000');
                  $('.J_ajax_submit_btn').text('添加').removeProp('disabled').removeClass('disabled');
                  $('.J_ajax_submit_btn').attr("disabledSubmit",'');
                }
                else if(data=='-9'){
                  ITENY.alert('提示','邮箱格式不正确',2,'5000');
                  $('.J_ajax_submit_btn').text('添加').removeProp('disabled').removeClass('disabled');
                  $('.J_ajax_submit_btn').attr("disabledSubmit",'');
                }
                else if(data=='-12'){
                  ITENY.alert('提示','邮箱被占用',2,'5000');
                  $('.J_ajax_submit_btn').text('添加').removeProp('disabled').removeClass('disabled');
                  $('.J_ajax_submit_btn').attr("disabledSubmit",'');
                }
                else {
                  ITENY.alert('提示','未知错误，请联系管理员！',2,'5000');
                  $('.J_ajax_submit_btn').text('添加').removeProp('disabled').removeClass('disabled');
                  $('.J_ajax_submit_btn').attr("disabledSubmit",'');
                }
              }
          });
        }
  });
});
</script>
</body>
</html>